package org.overmind.ieat.server.dao.provider;

import org.overmind.ieat.server.entity.Provider;
import org.overmind.ieat.server.exceptions.DatabaseException;

import java.util.List;

/**
 * @author eugene.karanda
 */
public interface ProviderDao {

    /**
     * @return All storage {@link org.overmind.ieat.server.entity.Provider} in {@link java.util.List} collection
     * @throws DatabaseException Indicates a problem with database
     */
    List<Provider> getProviderList() throws DatabaseException;

    /**
     * @param id key of the desired {@link org.overmind.ieat.server.entity.Provider}
     * @return {@link org.overmind.ieat.server.entity.Provider} object or <code>null</code> if object not found
     * @throws DatabaseException Indicates a problem with database
     */
    Provider findById(int id) throws DatabaseException;

    /**
     * @param id key of the {@link org.overmind.ieat.server.entity.Provider} to delete
     * @return <code>true</code> if removal was successful or <code>false</code> if current {@link org.overmind.ieat.server.entity.Provider} not found
     * @throws DatabaseException Indicates a problem with database
     */
    boolean deleteById(int id) throws DatabaseException;

    /**
     * @param provider object to save
     * @return code of new provider or null if saving failed
     * @throws DatabaseException Indicates a problem with database
     */
    Integer save(Provider provider) throws DatabaseException;

    /**
     * @param id id key of the {@link org.overmind.ieat.server.entity.Provider} to update
     * @param provider new value
     * @return updated value or null if update was be failed
     * @throws DatabaseException Indicates a problem with database
     */
    Provider update(int id, Provider provider) throws DatabaseException;

}
